<script>
export default {
  onLaunch: function () {
    // #ifdef MP-WEIXIN
    wx.cloud.init();
    // #endif
    console.log('App Launch');
  },
  onShow: function () {
    console.log('App Show');
    this.updateManagerFn()
  },
  onHide: function () {
    console.log('App Hide');
  },
  methods: {
    updateManagerFn() {
      const updateManager = uni.getUpdateManager();
      updateManager.onCheckForUpdate(function (res) {
        // 请求完新版本信息的回调
        console.log(res.hasUpdate, '请求完新版本信息的回调');
      });
      updateManager.onUpdateReady(function (res) {
        uni.showModal({
          title: '更新提示',
          content: '新版本已经准备好，是否重启应用？',
          showCancel: false,
          success(res) {
            if (res.confirm) {
              // 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
              updateManager.applyUpdate();
            }
          }
        });
      });
      updateManager.onUpdateFailed(function (res) {
        // 新的版本下载失败
        console.log('小程序版本下载失败', res)
        uni.showModal({
          title: '提示',
          content: '新版小程序下载失败\n请自行退出程序，手动卸载本程序，再运行',
          confirmText: "知道了"
        });
      });
    },
  }
};
</script>


<style lang="scss">
#page-loading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: #fff;
}
#page-loading:after {
  content: '';
  width: 40px;
  height: 40px;
  display: block;
  background-color: #5976ed;
  -webkit-animation: sk-rotateplane 1.2s infinite ease-in-out;
  animation: sk-rotateplane 1.2s infinite ease-in-out;
}

@-webkit-keyframes sk-rotateplane {
  0% {
    -webkit-transform: perspective(120px);
  }
  50% {
    -webkit-transform: perspective(120px) rotateY(180deg);
  }
  100% {
    -webkit-transform: perspective(120px) rotateY(180deg) rotateX(180deg);
  }
}

@keyframes sk-rotateplane {
  0% {
    transform: perspective(120px) rotateX(0deg) rotateY(0deg);
    -webkit-transform: perspective(120px) rotateX(0deg) rotateY(0deg);
  }
  50% {
    transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg);
    -webkit-transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg);
  }
  100% {
    transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
    -webkit-transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
  }
}
/*每个页面公共css */
page {
  height: 100%;
  font-size: 14px;
  color: #333;
  overflow: auto;
}
.uni-searchbar {
  padding: 0 !important;
}

.uni-table {
  /deep/ .uni-table-th-content {
    white-space: nowrap;
  }
  /deep/ .uni-table-td {
    white-space: nowrap;
  }
}
uni-datetime-picker {
  /deep/ .uni-date-x {
    padding-left: 0;
    padding-right: 0;
  }
  /deep/ .uni-date__x-input {
    padding-left: 0;
    padding-right: 0;
    height: 30px;
    line-height: 30px;
  }
  /deep/ .uni-date__icon-logo {
    display: none;
  }
  /deep/ .uni-input-input {
    font-size: 16px;
  }
  /deep/ .uni-date__icon-clear {
    top: -6px !important;
  }
}
.ui-checkbox {
  margin-right: 24px;
}
</style>
